layui.use('table', function () {
    var table = layui.table;
    table.render({
        elem: '#test'
        , url: '/Announcement/NoticPageList'
        , title: '用户数据表'
        , cols: [[
            { type: 'checkbox', fixed: 'left' }
            , { field: 'Ann_Id', title: 'ID', width: 80, fixed: 'left', sort: true }
            , { field: 'Ann_Number', title: '编号', width: 150 }
            , { field: 'Ann_Title', title: '标题', width: 150 }
            , { field: 'Ann_Content', title: '内容', width: 150 }
            , { field: 'CreateTime', title: '创建时间', width: 150, templet: "<div>{{Format(d.CreateTime,'yyyy-MM-dd hh:mm:ss')}}</div>" }
            , { field: 'Department', title: '部门ID', width: 150 }
            , { field: 'Publisher', title: '发布人', width: 150 }
            , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 200 }
        ]]
        , page: true
        , id: 'testReload'
    });
    table.on('tool(test)', function (obj) {
        var data = obj.data;
        //console.log(obj)
        if (obj.event === 'del') {
            layer.confirm('真的删除行么', function (index) {
                $.ajax({
                    type: "post",
                    data: data,
                    url: "/Announcement/NoticDel",
                    success: function (operate) {
                        if (operate.Success) {
                            obj.del();
                            layer.close(index);
                        } else {
                            layer("删除失败!");
                        }
                    }
                })
            })
            
        } else if (obj.event === 'edit') {
            var Id = data.Ann_Id;
            $.ajax({
                type: "post",
                url: "/Announcement/Update?id=" + Id,
                success: function (operate) {
                    if (operate.Success) {
                        window.location.href = "/Home/Notic_Update";

                    } else {
                        layer("发生异常!");
                    }
                }
            })
        }
    });
})
//列表刷新
function TableReload() {
    var table = layui.table;
    //获取页面管理员名称和时间
    var username= $("#note").val();
    alert(username);
    //上述方法等价于
    table.reload('testReload', {
        where: { //设定异步数据接口的额外参数，任意设
            username: username,
        }
    });
};
//查询点击事件
$("#check").click(function () {
    TableReload();

});